<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>DOM</title>
  </head>
  <body>
    <div class="test" id="test1">
      <p class="test_p"></p>
    </div>
    <div class="test">
      <p class="test_p"></p>
    </div>
    <div class="test">
      <p class="test_p"></p>
    </div>
    <form name="from"></form>
    <script>
      /*
        元素的获取
        */
      //getElementById:根据id获取元素节点 ----> 返回的是唯一节点
      var test1 = document.getElementById("test1");
      console.log(test1);
      //getElementsByTagName:根据标签名过去元素节点 ----> 返回的是节点列表 类数组
      var div = document.getElementsByTagName("div");
      console.log(div);
      //getElementsByClassName:根据class名来获取元素节点 -----> 返回的是节点列表 类数组
      var test = document.getElementsByClassName("test");
      console.log(test);
      //getElementsByName :根据属性name名来获取元素节点 -----> 返回的是节点列表 类数组
      var from = document.getElementsByName('from');
      console.log(from)
      //querySelector querySelectorAll
      var test2 = document.querySelector('.test1')
      var test_p = document.querySelectorAll('.test_p')
    </script>
  </body>
</html>
